package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.RetrievalRecord;
import com.ruoyi.system.service.IRetrievalRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 店铺提现记录Controller
 *
 * @author ruoyi
 * @date 2021-03-10
 */
@RestController
@RequestMapping("/system/record")
public class RetrievalRecordController extends BaseController
{
    @Autowired
    private IRetrievalRecordService retrievalRecordService;

    /**
     * 查询店铺提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:list')")
    @GetMapping("/list")
    public TableDataInfo list(RetrievalRecord retrievalRecord)
    {
        startPage();
        List<RetrievalRecord> list = retrievalRecordService.selectRetrievalRecordList(retrievalRecord);
        return getDataTable(list);
    }

    /**
     * 导出店铺提现记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:record:export')")
    @Log(title = "店铺提现记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RetrievalRecord retrievalRecord)
    {
        List<RetrievalRecord> list = retrievalRecordService.selectRetrievalRecordList(retrievalRecord);
        ExcelUtil<RetrievalRecord> util = new ExcelUtil<RetrievalRecord>(RetrievalRecord.class);
        return util.exportExcel(list, "record");
    }

    /**
     * 获取店铺提现记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:record:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return AjaxResult.success(retrievalRecordService.selectRetrievalRecordById(id));
    }

    /**
     * 新增店铺提现记录
     */
    @PreAuthorize("@ss.hasPermi('system:record:add')")
    @Log(title = "店铺提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RetrievalRecord retrievalRecord)
    {
        return toAjax(retrievalRecordService.insertRetrievalRecord(retrievalRecord));
    }

    /**
     * 修改店铺提现记录
     */
    @PreAuthorize("@ss.hasPermi('system:record:edit')")
    @Log(title = "店铺提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RetrievalRecord retrievalRecord)
    {
        return toAjax(retrievalRecordService.updateRetrievalRecord(retrievalRecord));
    }

    /**
     * 删除店铺提现记录
     */
    @PreAuthorize("@ss.hasPermi('system:record:remove')")
    @Log(title = "店铺提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(retrievalRecordService.deleteRetrievalRecordByIds(ids));
    }
}
